<template>
    <div class="tofwjjphbox">
        <h5>
            <template v-if="title">
                <span class="selected" v-html="title"></span>
            </template>
            <template v-else>
                <span :class="{'selected':tabIndex==1}" @click="getTab(1)" v-t="'advertiser.Advertising'">ADVERTISING</span> 
                <span :class="{'selected':tabIndex==3}" @click="getTab(3)" v-t="'advertiser.Bonus'">BONUS</span>
            </template>
        </h5>
        <div class="rklph-scroll" v-if="lists.length>0">
            <div class="txtItem" v-for="(dt,index) in lists" :key="index">
                <div :class="`icon mc${index+1}`">{{index+1}}</div>
                <div class="con">
                    <div class="title">
                        <label>{{dt[keyName]}}</label>
                        <span>{{keyType}} <em>{{dt[keyValue].decimalTwoString?dt[keyValue].decimalTwoString:dt[keyValue]}}</em></span>
                    </div>
                    <template v-if="dt[keyValue].num">
                        <progress-bar v-if="maxValue || maxValue==0" :width="`${parseFloat(dt[keyValue].num) / maxValue *100}%`"/>
                    </template>
                    <template v-else>
                        <progress-bar v-if="maxValue || maxValue==0" :width="`${parseFloat(dt[keyValue]) / maxValue *100}%`"/>
                    </template>
                </div>
            </div>
        </div>
        <div class="norankdata" v-else v-t="'dataNo'">No Data</div>
    </div>
</template>

<script>
import { reactive,toRefs,getCurrentInstance } from 'vue'
import {useRoute,useRouter} from 'vue-router'
import { useStore } from 'vuex'
import { useI18n } from 'vue-i18n'

export default {
    components:{
       
    },
    props:{
        title:'',
        lists:Array,
        keyName:{
            type:String,
            default:'name'
        },
        keyType:{
            type:String,
            default:'visits'
        },
        keyValue:{
            type:String,
            default:'name'
        },
        maxValue:''
    },
    setup(props,context){
        const router = useRouter()
        const route = useRoute()
        const store = useStore()
        const {proxy} = getCurrentInstance()
        const {t} = useI18n()

        const state = reactive({
            tabIndex:1
        })

        const getTab=(index)=>{
            state.tabIndex = index
            context.emit('onTab',index)
        }

        return{
            ...toRefs(state),
            getTab
        }
    }
}
</script>

<style lang="scss" scoped>
    .tofwjjphbox{
        display: flex;
        width: 100%;
        height: 100%;
        flex-flow: column;
        font-size: 22px;
        font-weight: 500;
        color: #FFFFFF;
        font-family: Inter-Medium, Inter;
        font-weight: 500;
        line-height: normal;
        h5{
            // display: flex;
            // align-items: center;
            // justify-content: center;
            font-size: 22px;
            font-family: Inter-Semi Bold, Inter;
            color: #67F8FF;
            text-align: left;
            padding: 0 30px;
            line-height: normal;
            height:60px;
            overflow: hidden;
            flex-shrink: 0;
            line-height: 34px;
            span{
                display: inline-block;
                color: #2E78A7;
                padding: 10px 16px 4px 16px;
                &.selected{
                    background: #004AD9;
                    color: #67F8FF;
                    border-left: 4px solid #67F8FF;
                }
                &+span{
                    margin-left:20px ;
                }
            }
        }
        .rklph-scroll{
            flex: 1;
            height: 100%;
            overflow: hidden;
            overflow-y:auto ;
            -webkit-overflow-scrolling:touch;
        }
        .txtItem{
            display: flex;
            height: 56px;
            margin: 15px 0 0 0;
            padding: 0 10px;
            overflow: hidden;
            border: 0;
            
            .icon{
                display: flex;
                width: 40px;
                height: 47px;
                line-height: normal;
                justify-content: center;
                align-items: center;
                flex-shrink: 0;
                text-align: center;
                font-size: 26px;
                font-weight: normal;
                background: url(/images/flowRanking/bs.png) left center no-repeat;
                background-size: 100% 100%;
                margin: 10px 0 0 0;
                &.mc1{
                    background-image: url(/images/flowRanking/one.png) 
                }
                &.mc2{
                    background-image: url(/images/flowRanking/two.png) 
                }
                &.mc3{
                    background-image: url(/images/flowRanking/three.png) 
                }
            }
            .con{
                flex: 1;
                padding: 6px 0 0 10px;
                .title{
                    display: flex;
                    width: 100%;
                    font-size: 22px;
                    margin: 0 0 5px 0;
                    label{
                        flex: 1;
                        display: block;
                        white-space: nowrap;
                        text-overflow: ellipsis;
                        overflow: hidden;
                        word-break: break-all;
                        width: 0;
                        font-family: Inter-Semi Bold, Inter;
                        font-weight: normal;
                        color: #FFFFFF;
                    }
                    span{
                        font-size: 22px;
                        color: #89A6EE;
                        margin: 0;
                        transform: scale(0.7);
                        font-family: Inter-Medium, Inter;
                        font-weight: 500;
                        em{
                            font-style: normal;
                            color: #C7D6F8;
                        }
                    }
                }
            }
        }
        
    }
     .norankdata{
        display: flex;
        width: 100%;
        height: 100%;
        align-items: center;
        justify-content: center;
        font-size: 22px;
        color: #FFFFFF;
        font-family: Inter-Medium, Inter;
        font-weight: 500;
    }
</style>